package com.qww.test06;

public class Test06 {
    public static void main(String[] args) {
        System.out.println(new A());
        System.out.println(new A(1));
        System.out.println(new A(2, "hello", 300.0));

        System.out.println(new B(1, "hello"));
    }
}
class A {
    int x;
    String s;
    double y;

    A() {
        this(0, "", 0.0);
    }

    A(int x) {
        this(x, "", 0.0);
    }

    A(int x, String s, double y) {
        this.x = x;
        this.s = s;
        this.y = y;
    }

    public String toString() {
        return "x=" + x + ", s=" + s + ", y=" + y;
    }
}

class B {
    int x;
    String s;

    B() {
        x = 0;
        s = "";
    }

    B(int x) {
        this("");
        this.x = x;
    }

    B(String s) {
        this.s = s;
    }


    B(int x, String s) {
        this(x);
        // this(s);  // Error:(57, 13) java: 对this的调用必须是构造器中的第一个语句
        this.s = s;
    }

    public String toString() {
        return "x=" + x + ", s=" + s;
    }
}